package com.oromwin.repos.common;

import java.util.regex.PatternSyntaxException;

import com.oromwin.repos.common.helper.DBHelper;

public class Query {
//    private Log log = Logger.getLog(Query.class);
    StringBuilder sb = null;
    public Query(String str) {
        sb = new StringBuilder(str);
    }
    public StringBuilder append(String str) {
        return sb.append(str);
    }
    public void delete(int last) {
        int end = sb.length();
        int start = end - last;
        sb.delete(start, end);
    }
    private String escape(String str) {
        try {
            if (DBHelper.isOracle) {
                str = str.replaceAll("`", "");
                str = str.replaceAll(";", "");
            } else if (DBHelper.isMySQL) {
                if (str.indexOf("\\\\") > 0) {
                } else {
                    str = str.replace("\\", "\\\\");
                }
            }
        } catch (PatternSyntaxException e) {
            e.printStackTrace();
        }
        return str;
    }
    public String toString() {
        return escape(sb.toString());
    }
}
